<template>
    <el-form :model="student.grades" ref="formRef">
        <el-form-item label="网站前端开发" prop="frontend" :rules="[{ required: true, message: '请输入成绩'}]">
            <el-input v-model="student.grades.frontend" type="number"></el-input>
        </el-form-item>
        <el-form-item label="专业英语" prop="english" :rules="[{ required: true, message: '请输入成绩'}]">
            <el-input v-model="student.grades.english" type="number"></el-input>
        </el-form-item>
        <el-form-item label="Python程序设计" prop="python" :rules="[{ required: true, message: '请输入成绩'}]">
            <el-input v-model="student.grades.python" type="number"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">提交</el-button>
            <el-button @click="onCancel">取消</el-button>
        </el-form-item>
    </el-form>
</template>

<script setup>
import { ref } from 'vue'

const formRef = ref(null)
const props = defineProps({
    student: {
        type: Object,
        required: true
    }
})

const emit = defineEmits(['submit'])

const onSubmit = () => {
    formRef.value.validate((valid) => {
        if (valid) {
            emit('submit')
        }
    })
}

const onCancel = () => {
    history.back()
}
</script>